// flask所有api的封装，慢慢的会重构解偶成算法后台
import {mapActions, mapState} from "vuex";
import appConfig from "../../api/appConfig";
import flaskApi from "../flaskApi";

export default {
    flaskQueueQuery(redis_id, success, fail){
        let url = flaskApi.QUEUE_QUERY + '?redis_id=' + redis_id
        uni.request({
            url: url,
            success: success,
            fail: fail
        })
    },


    flaskPredict(user_name, token, data, success, fail){
        let formData = {
            user_name: user_name,
            token: token,
            data: JSON.stringify( data )
        }

        uni.request({
            url: flaskApi.PREDICT,
            method: "POST",
            header: {
                'content-type': 'application/x-www-form-urlencoded'
            },
            data: formData,
            success: success,
            fail: fail
        })
    },

    flaskPredictV1(user_name, token, data, success, fail){
        let formData = {
            user_name: user_name,
            token: token,
            data: JSON.stringify( data )
        }

        uni.request({
            url: flaskApi.PREDICT_V1,
            method: "POST",
            header: {
                'content-type': 'application/x-www-form-urlencoded'
            },
            data: formData,
            success: success,
            fail: fail
        })
    },


    flaskFileDelete(user_name, token, file_name, success, fail){
        let formData = {
            user_name: user_name,
            token: token,
            img_name: file_name
        }
        uni.request({
            url: flaskApi.FILE_DELETE,
            method: "POST",
            header: {
                'content-type': 'application/x-www-form-urlencoded'
            },
            data: formData,
            success: success,
            fail: fail
        })
    }
}
